import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views//home/Home.vue'
import Sign from "../views/Login/sign"
import Countlogin from "../views/Login/countlogin"
import Phonelogin from "../views/Login/phonelogin"
import Page from "../views/Page/page"
import Work from "../views/Work/work"
import Manage from "../views/Manage/manage"
import Material from "../views/Material/material"
import Report from "../views/Report/report"
import Newactivity from "../views/Work/newactivity"
import Sort from "../views/Work/sort"
import Calendar from "../views/Work/calendar"
import Videomessage from "../views/Work/videomessage"

Vue.use(VueRouter)
//解决路由重复点击报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  // 首页页面路由
  {
    path: '/',
    name: 'Home',
    component: Home
  }
  ,
  // 注册登录页面
  {
    path: '/sign',
    name: 'Sign',
    component: Sign
  },
  {
    path: '/countlogin',
    name: 'Countlogin',
    component: Countlogin
  },
  {
    path: '/phonelogin',
    name: 'Phonelogin',
    component: Phonelogin
  },
  //page开始页面
  {
    path: '/page',
    name: 'Page',
    component: Page,
    //工作台页面
    children: [
      {
        path: '/work',
        name: 'Work',
        component: Work,
        meta: {
          requireAuth: true,
          title: "首页--主页部分"
        },
      },
      {
        //工作台/新建活动(默认页面)--活动基本信息页面
        path: '/newactivity',
        name: 'Newactivity',
        component: Newactivity,
      },
      //第二步，分群页面
      {
        path: '/sort',
        name: 'Sort',
        component: Sort,
        meta: {
          requireAuth: true,
          title: "首页--分群部分"
        },
      },
       //点击日历框跳转
       {
        path: '/calendar',
        name: 'Calendar',
        component: Calendar,
        meta: {
          requireAuth: true,
          title: "首页--日历部分"
        },
      },
       //点击短信跳转
       {
        path: '/videomessage',
        name: 'Videomessage',
        component:Videomessage,
        meta: {
          requireAuth: true,
          title: "首页--编辑创意--短信部分"
        },
      },
      {
        path: '/manage',
        name: 'Manage',
        component:Manage,
        meta: {
          requireAuth: true,
          title: "首页--客户管理部分"
        },
      },
      {
        path: '/material',
        name: 'Material',
        component: Material,
        meta: {
          requireAuth: true,
          title: "首页--素材管理部分"
        },
      },
      {
        path: '/report',
        name: 'Report',
        component: Report,
        meta: {
          requireAuth: true,
          title: "首页--报告部分"
        },
      },
    ]
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
